﻿using Exiled.API.Enums;
using Exiled.API.Features;
using HarmonyLib;
using RgCore.CustomSide;

namespace CustomCharacter.Patches
{
    [HarmonyPatch(typeof(SideManager), nameof(SideManager.GetSide), typeof(Player))]
    public static class GetSidePatch
    {
        [HarmonyPrefix]
        public static bool Prefix(Player player, ref CustomSide __result)
        {
            var cc = player.GetCharacterInstance();
            if (cc == null || cc?.Attribute.FollowRole == true)
            {
                return true;
            }
            __result = cc.Attribute.SideId.GetSideById() ?? Side.None.GetSide();
            return false;
        }
    }
}
